package com.compus_help.service.impl;

import com.compus_help.Mapper.adminOrderMapper;
import com.compus_help.common.PageResult;
import com.compus_help.controller.admin.adminOrderController;
import com.compus_help.entity.DTO.OrderPageDTO;
import com.compus_help.entity.Pojo.Order;
import com.compus_help.service.adminOrderService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class adminOrderServiceImpl implements adminOrderService {

    private static final Logger log = LoggerFactory.getLogger(adminOrderController.class);

    @Autowired
    private adminOrderMapper adminOrderMapper;

    @Override
    public PageResult getOrderPage(OrderPageDTO orderPageDTO) {
        //订单分页查询
        log.info("订单分页查询");
        //设置分页参数
        PageHelper.startPage(orderPageDTO.getPage(),orderPageDTO.getPageSize());
        Page<Order> page = adminOrderMapper.getOrderPage(orderPageDTO);
          log.info("第一条记录: {}", page.getResult().get(0));
        return new PageResult(page.getTotal(),page.getResult());
    }


    //TODO 管理员订单后续功能
}
